<?php
    session_start();
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    $oid = $_REQUEST['oid'];

        $count ="select COUNT(*) as n from segimagenes where hcnsolexa = '".$oid."'";
        $res = $con->query($count);
    
    while($res2 = mssql_fetch_array($res)){
        $n = $res2['n'];
    }
    if ($n == 0){
        
        $inser= "insert into segimagenes(hcnsolexa,solautori,fecsolau,usu_oidsa)values('".$oid."','1',GETDATE(),'".$_SESSION['usuario']."')";
        $con->query($inser);
    }
    else {
        
        $update ="update segimagenes
                    set solautori ='1',
                    fecsolau = GETDATE(),
                    usu_oidsa ='".$_SESSION['usuario']."'
                  where hcnsolexa ='".$oid."'";
        $con->query($update);
   }
       
    $con->cerrarConexion();
    
 
?>